#pragma once
#include "Ball.h"
#include "DrawableElement.h"
#include "NoIntersectException.h"
#include "ParallelStraightsException.h"
#include <list>

class TriangularObstacle  : public DrawableElement {

public:
	TriangularObstacle( Position * p1, Position * p2, Position * p3 );
	TriangularObstacle(void);
	~TriangularObstacle(void);
	void setP1(Position * p1);
	void setP2(Position * p1);
	void setP3(Position * p1);
	Position * getP1(void);
	Position * getP2(void);
	Position * getP3(void);
	int include(Position * point);
	virtual void setPosition(Position *position);
	virtual Position * getPosition();
	virtual Color * getElementColor();
	virtual void setElementColor( Color * color);
	virtual Color * getLineColor();
	virtual void setLineColor( Color * color);
	virtual Texture * getTexture();
	virtual void setTexture(Texture *texture);
	virtual void draw();
	virtual float getMinXPos();	//Para utilizar los siguientes metodos, la posicion debera estar ya seteada sino, devolvera 0
	virtual float getMinYPos();
	virtual float getMaxXPos();
	virtual float getMaxYPos();
	virtual void evaluateCollision(Ball * ball);

private:

	Position * p1;
	Position * p2;
	Position * p3;

	float m1_2,m1_3,m2_3;
	float ord1_2,ord1_3,ord2_3;

	Collision * evaluateCollisionEdge(Ball * ball, Position * point1, Position * point2);
	Collision * evaluateCollisionVertex(Ball * ball, Position * point);
	int getPointEdge(Position * p, Position * point1, Position * point2 );
	int getPixelXIntersection(float m1, float b1, float m2, float b2);

	Position * position;
	Texture * texture;
	Color * elementColor;
	Color * lineColor;

public:	
	
};
